package metu.tespit.entity.course;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.NotNull;


/**
 
 * @created May 23, 2012
 */
@Entity
@Table(name="activity")
public class Activity implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 2251171343769735880L;

	@Id @GeneratedValue
	private Long id;
	
	@ManyToOne
	private Schedule schedule;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date dueDate;
	
	@NotNull
	private String name;
	
	private String desciption;
	
	@OneToMany(mappedBy="uploaderActivity", cascade=CascadeType.ALL)
	private List<ProjectDocument> projectDocuments = new ArrayList<ProjectDocument>();
	
	private Boolean submissionActivity;

	private Boolean warningEmailSent;
    private Boolean dueDateOverEmailSent;

	@OneToOne
	private Activity reviewActivity;
	
	@OneToMany(cascade=CascadeType.ALL)
	private List<ReviewPair> reviewPairs = new ArrayList<ReviewPair>();
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesciption() {
		return desciption;
	}

	public void setDesciption(String desciption) {
		this.desciption = desciption;
	}

	public List<ProjectDocument> getProjectDocuments() {
		return projectDocuments;
	}

	public void setProjectDocuments(List<ProjectDocument> projectDocuments) {
		this.projectDocuments = projectDocuments;
	}

	public void setSchedule(Schedule schedule) {
		this.schedule = schedule;
	}

	public Schedule getSchedule() {
		return schedule;
	}

	public void setSubmissionActivity(Boolean submissionActivity) {
		this.submissionActivity = submissionActivity;
	}

	public Boolean getSubmissionActivity() {
		return submissionActivity;
	}

	public void setReviewActivity(Activity reviewActivity) {
		this.reviewActivity = reviewActivity;
	}

	public Activity getReviewActivity() {
		return reviewActivity;
	}

	public void setReviewPairs(List<ReviewPair> reviewPairs) {
		this.reviewPairs = reviewPairs;
	}

	public List<ReviewPair> getReviewPairs() {
		return reviewPairs;
	}

    public Boolean getWarningEmailSent() {
        if (warningEmailSent == null) {
            warningEmailSent = false;
        }
        return warningEmailSent;
    }

    public void setWarningEmailSent(Boolean warningEmailSent) {
        this.warningEmailSent = warningEmailSent;
    }

	public Boolean getDueDateOverEmailSent() {
		return dueDateOverEmailSent;
	}

	public void setDueDateOverEmailSent(Boolean dueDateOverEmailSent) {
		this.dueDateOverEmailSent = dueDateOverEmailSent;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((dueDate == null) ? 0 : dueDate.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Activity other = (Activity) obj;
		if (dueDate == null) {
			if (other.dueDate != null)
				return false;
		} else if (!dueDate.equals(other.dueDate))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
    
	
    
}
